<template>
  <a-config-provider :locale="locale">
    <div id="app">
      <router-view/>
    </div>
  </a-config-provider>
</template>
<script>
  import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
  import zhTW from 'ant-design-vue/lib/locale-provider/zh_TW'
  import enquireScreen from '@/utils/device'
  import moment from 'moment'
  import 'moment/locale/zh-tw';

  moment.locale('zh-tw')
  export default {
    data () {
      return {
        locale: zhTW,
      }
    },
    created () {
      let that = this
      enquireScreen(deviceType => {
        // tablet
        if (deviceType === 0) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        // mobile
        else if (deviceType === 1) {
          that.$store.commit('TOGGLE_DEVICE', 'mobile')
          that.$store.dispatch('setSidebar', false)
        }
        else {
          that.$store.commit('TOGGLE_DEVICE', 'desktop')
          that.$store.dispatch('setSidebar', true)
        }

      })

      //获取本地缓存中的语言配置，并切换
      let language = this.$ls.get("language");
      if( language === 'zh-CN'){
        this.locale =  zhCN
      } else if(language === 'zh-TW'){
        this.locale = zhTW
      }else{
        this.locale = zhTW
        debugger
      }

    }
  }
</script>
<style>
  #app {
    height: 100%;
  }
</style>